Else statement to show connection successful [closed]
Posted
by
Craig Smith
on Programmers
See other posts from Programmers
or by Craig Smith
Published on 2012-11-30T00:43:20Z
Indexed on
2012/11/30
5:25 UTC
Read the original article
Hit count: 229
I am trying to write a script to test a database connection, at the moment it will only display text if the connection doesn't work, I am stuck with trying to create an else statement to display "Connection Successful" if it works.
Here's my code so far. Any help appreciated :)
<?
$conn = @mysql_connect("localhost", "root", "");
if (!$conn) {
die("Connection failed: " .mysql_error());
}
?>
© Programmers or respective owner